package fr.cephb.lexyacc;
/** A node for a logical NOT */
public class NotNode extends YNode {

	public NotNode(Node node)
		{
		super(node);
		}
	
	public String getName()
		{
		return "not";
		}
	
	/**
	 * @return inverse the boolean value of the child node 
	 * or return null if it wasn't a boolean value
	 */
	@Override
	public Object eval(Context ctx)
		{
		Object o1 = at(0).eval(ctx);
		if(o1==null || !(o1 instanceof Boolean)) return null;
		return !Boolean.class.cast(o1).booleanValue();
		}

}
